package bocchi.card;

import bocchi.base.BaseCustomCard;
import bocchi.BocchiCore;
import bocchi.base.BaseCustomPower;
import bocchi.general.Util;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class OnlyGhost extends BaseCustomCard {
    private static final String RAW_ID = OnlyGhost.class.getSimpleName();
	public static final String GAME_ID = BocchiCore.getGameID(RAW_ID);

    public OnlyGhost() {
        super(RAW_ID);
    }

    @Override
    public void use(AbstractPlayer player, AbstractMonster monster) {
        AbstractPower power = new BaseCustomPower(RAW_ID, AbstractPower.PowerType.BUFF, player) {
            @Override
            public void onCardDraw(AbstractCard card) {
                List<Integer> costs = player.hand.group.stream().mapToInt(c -> c.cost).collect(ArrayList::new, List::add, List::addAll);
                Collections.shuffle(costs, AbstractDungeon.cardRandomRng.random);
                for (int i = 0; i < costs.size(); i++) {
                    player.hand.group.get(i).setCostForTurn(costs.get(i));
                }
            }
        };

        Util.applyPower(player, player, power);
    }
}
